# 多层继承
# 继承关系顺序 Phone->SmartPhone->XiaomiPhone
# 同层关系XiaomiPhone和iPhone
class Phone(object):
    def __init__(self, phone_number):
        self.number = phone_number

    def call(self):
        print('手机:' + self.number + '正在打电话')


class SmartPhone(Phone):
    def __init__(self, phone_number, system):
        Phone.__init__(self, phone_number)
        self.system = system

    def useNetwork(self):
        print(self.system + '手机可以使用网络服务')


class XiaomiPhone(SmartPhone):
    def __init__(self, phone_number, system, model):
        SmartPhone.__init__(self, phone_number, system)
        self.model = model

    def play(self):
        print(self.model + '可以用来玩' + self.system + '端的游戏')


class IPhone(SmartPhone):
    def __init__(self, phone_number, system, model):
        SmartPhone.__init__(self, phone_number, system)
        self.model = model

    def play(self):
        print(self.model + '可以用来玩' + self.system + '端的游戏')


m = XiaomiPhone('13215546701', 'android', 'xiaomi10')
m.call()
m.play()
m.useNetwork()
m1 = IPhone('1123441111', 'apple', 'iphone14 pro')
m1.play()


# 多重继承初始化问题 钻石继承存在问题Person初始化会多次调用
# 通过super()可变参数解决这个问题
# MRO顺序 Method Resolution Order 方法解析顺序
class Person(object):
    def __init__(self, pid):
        self.id = pid
        print('Person init')


class Father(Person):
    def __init__(self, name, *args):
        super(Father, self).__init__(*args)
        # Person.__init__(self, pid)
        self.name = name
        print('Father init')


class Mother(Person):
    def __init__(self, age, *args):
        super(Mother, self).__init__(*args)
        # Person.__init__(self, pid)
        self.age = age
        print('Mother init')


class Son(Father, Mother):
    def __init__(self, gender, name, age, pid):
        super(Son, self).__init__(name, age, pid)
        # Father.__init__(self, pid, name)
        # Mother.__init__(self, pid, age)
        self.gender = gender
        print('Son init')


s = Son('man', 'Jim', 30, 1011)
print(Son.mro())
